//JavaScript Framework 2.0 Code
try {
	Type.registerNamespace('com.yonyou.ncmm_pac_pda.WrListPageController');
	com.yonyou.ncmm_pac_pda.WrListPageController = function() {
		com.yonyou.ncmm_pac_pda.WrListPageController.initializeBase(this);
		this.initialize();
	}
	function com$yonyou$ncmm_pac_pda$WrListPageController$initialize() {
		//you can programing by $ctx API
		//get the context data through $ctx.get()
		//set the context data through $ctx.push(json)
		//set the field of the context through $ctx.put(fieldName, fieldValue)
		//get the parameter of the context through $ctx.param(parameterName)
		//Demo Code:
		//    var str = $ctx.getString();      //获取当前Context对应的字符串
		//    alert($ctx.getString())          //alert当前Context对应的字符串
		//    var json = $ctx.getJSONObject(); //获取当前Context，返回值为json
		//    json["x"] = "a";        //为当前json增加字段
		//    json["y"] = [];           //为当前json增加数组
		//    $ctx.push(json);            //设置context，并自动调用数据绑定
		//
		//    put方法需手动调用databind()
		//    var x = $ctx.get("x");    //获取x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.databind();            //调用数据绑定才能将修改的字段绑定到控件上
		//    var p1 = $param.getString("p1");   //获取参数p2的值，返回一个字符串
		//    var p2 = $param.getJSONObject("p2");   //获取参数p3的值，返回一个JSON对象
		//    var p3 = $param.getJSONArray("p3");   //获取参数p1的值，返回一个数组

		//your initialize code below...

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$evaljs(js) {
		eval(js)
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$viewPage0_onload(sender, args) {
	}

	// 由列表跳转明细页面
	function com$yonyou$ncmm_pac_pda$WrListPageController$onitemclick(sender, args) {
		// 获取当前行内容
		var row = $id("listviewdefine0").get("row");
		// $alert(row);
		row = $stringToJSON(row);
		// 离散mo是订单id，流程mo是行id，获取id是为了从本地数据库中取其他字段
		var orderid = row.orderid;
		// 单击行跳转到详情页面
		$view.open({
			"viewid" : "com.yonyou.ncmm_pac_pda.WrMODetailPage",
			"isKeep" : "true",
			// "id" : orderid
			 "row" : row
		});
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button0_onclick(sender, args) {
		// 返回即关闭当前页面
		$view.close();

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button1_onclick(sender, args) {
		// 按照默认查询条件查询当天生产订单数据

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button2_onclick(sender, args) {
		// 默认查询本周生产订单数据

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button3_onclick(sender, args) {
		// 默认查询本月生产订单数据

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$onitemdelete(sender, args) {
		if ($confirm("确认要删除当前行数据么？")) {
			var row = $id("listviewdefine0").get("row");
			deleteRow($stringToJSON(row));

		}
	}

	function deleteRow(row) {
		var datas = $ctx.getJSONArray("orders");
		for (var i = 0; i < datas.length; i++) {
			var everyRow = datas[i];
			if (everyRow.id == row.id) {
				datas.splice(i, 1);
				break;
			}
		}
		var json = {};
		json["orders"] = datas;
		$ctx.push(json);
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$onload(sender, args) {
		// 实际是由查询页面返回的数据进行加载
		//var json = {};
		//json["orders"] = $param.getJSONArray("result");
		//$ctx.push(json);
		// NCMMPubUtil.notifyFilter("code", "listviewdefine0", ["billcode", "material"]);
		// 如果本地没有数据就显示为空，如果本地有数据则显示本地全部数据
		NCMMPubUtil.createTable(WRMOVO);
		for (var i = 0; i < 20; i++) {
			var order = {
				"orderid" : i,
				"billcode" : i,
				"rowno" : "10",
				"material" : "material" + i,
				"planputnum" : 100 + i,
				"planputastnum" : 100 + i,
				"batchcode" : 1000 + i,
				"wrastnum" : 200 + i,
				"wrnum" : 200 + i,
				"planstartdate" : "2016-10-11 16:30:50",
				"planenddate" : "2016-10-12 16:30:50"
			}
			NCMMPubUtil.insertVO(WRMOVO, order);
		}
		NCMMPubUtil.queryVOByConditions(WRMOVO, null, function(data) {
			var json = {
				orders : data
			};
			$ctx.push(json);
		});
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton0_onclick(sender, args) {
		$menu.openDropDownList({
			"controlid" : "imagebutton0",
			"dropDownListWidth" : "130",
			"background" : "#2e2e2e",
			"color" : "#ffffff",
			"font-size" : "15",
			"halign" : "center",
			"split-color" : "#eeeeee",
			"panelstyle" : "round-div",
			"border-color" : "#d2d2d2",
			"showtype" : "right",
			"dropItemsArray" : [{
				"name" : "主界面",
				"action" : "menu1_click()"
			}, {
				"name" : "数据管理",
				"action" : "menu2_click()"
			}, {
				"name" : "业务设置",
				"action" : "menu3_click()"
			}, {
				"name" : "注销",
				"action" : "menu4_click()"
			}, {
				"name" : "退出",
				"action" : "menu5_click()"
			}]
		})

	}

	function menu1_click() {
		// 跳转到主界面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.HomePage",
			isKeep : "false"//
		})
	}

	function menu2_click() {
		// 跳转到数据管理界面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.DM_main",
			isKeep : "false"//
		})
	}

	function menu3_click() {
		// 跳转到业务设置界面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.LoginSettingPage",
			isKeep : "false"//
		})
	}

	function menu4_click() {
		// 跳转到登录界面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.LoginPage", 
			isKeep : "false"//
		})
	}

	function menu5_click() {
		// 关闭app
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button4_onclick(sender, args) {
		// 扫描记录打开详情画面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.WrDetailPage",
			isKeep : "true"
		})
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button6_onclick(sender, args) {
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button5_onclick(sender, args) {
		// 扫描记录打开扫描记录列表画面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.WrScanListPage",
			isKeep : "true"
		})

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$button7_onclick(sender, args) {

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$search0_onsearch(sender, args) {

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton1_onclick(sender, args) {
		$scanner.open({
			bindfield : "code",
			callback : "myCallBack()"
		});
		//$view.open({
		//"viewid" : "com.yonyou.ncmm_pac_pda.WrScanPage"
		//});
	}

	function myCallBack() {
		var code = $ctx.getString("code");
		$id("search0").set("keyword", code);
		// $ctx.put("code", code);
		$ctx.dataBind();
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton2_onclick(sender, args) {
		// 点击查询按钮弹出查询条件画面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.WrQueryPage",
			isKeep : "true"
		})

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$onchange(sender, args) {
		// 按照查询条件进行快速查询
		// NCMMPubUtil.quickFilter();
	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton3_onclick(sender, args) {

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$checkAll(sender, args) {
		// 全选按钮逻辑
		$ctx.dataCollect();
		var isallchecked = $id(sender).get("checked");
		var orders = $ctx.getJSONArray("orders");
		if (orders == null)
			return;
		for (var i = 0; i < orders.length; i++) {
			orders[i]["ischecked"] = isallchecked;
		}

		var json = {};
		json["orders"] = orders;
		json["isallchecked"] = isallchecked;
		$ctx.push(json);

	}

	function com$yonyou$ncmm_pac_pda$WrListPageController$checkSinge(sender, args) {
		// 单选按钮逻辑
		$ctx.dataCollect();
		var ischecked = $id(sender).get("checked");
		var isallchecked = true;
		if (ischecked == false) {
			isallchecked = false;
		} else {
			var orders = $ctx.getJSONArray("orders");
			for (var i = 0; i < orders.length; i++) {
				if (orders[i]["ischecked"] == null || orders[i]["ischecked"] == "false") {
					isallchecked = false;
					break;
				}
			}
		}

		var json = {};
		json["orders"] = orders;
		json["isallchecked"] = isallchecked;
		$ctx.push(json);
	}


	com.yonyou.ncmm_pac_pda.WrListPageController.prototype = {
		checkSinge : com$yonyou$ncmm_pac_pda$WrListPageController$checkSinge,
		checkAll : com$yonyou$ncmm_pac_pda$WrListPageController$checkAll,
		imagebutton3_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton3_onclick,
		onchange : com$yonyou$ncmm_pac_pda$WrListPageController$onchange,
		imagebutton2_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton2_onclick,
		imagebutton1_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton1_onclick,
		search0_onsearch : com$yonyou$ncmm_pac_pda$WrListPageController$search0_onsearch,
		button7_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button7_onclick,
		button5_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button5_onclick,
		button6_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button6_onclick,
		button4_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button4_onclick,
		button3_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button3_onclick,
		imagebutton0_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$imagebutton0_onclick,
		onload : com$yonyou$ncmm_pac_pda$WrListPageController$onload,
		onitemdelete : com$yonyou$ncmm_pac_pda$WrListPageController$onitemdelete,
		button2_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button2_onclick,
		button1_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button1_onclick,
		button0_onclick : com$yonyou$ncmm_pac_pda$WrListPageController$button0_onclick,
		onitemclick : com$yonyou$ncmm_pac_pda$WrListPageController$onitemclick,
		onload : com$yonyou$ncmm_pac_pda$WrListPageController$onload,
		viewPage0_onload : com$yonyou$ncmm_pac_pda$WrListPageController$viewPage0_onload,
		initialize : com$yonyou$ncmm_pac_pda$WrListPageController$initialize,
		evaljs : com$yonyou$ncmm_pac_pda$WrListPageController$evaljs
	};
	com.yonyou.ncmm_pac_pda.WrListPageController.registerClass('com.yonyou.ncmm_pac_pda.WrListPageController', UMP.UI.Mvc.Controller);
} catch(e) {
	$e(e);
}
